package demo7;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-04-17
 * Time: 12:13
 */

//class WorkSource{
//    private String s;
//    //构造方法
//    public WorkSource(){
//        System.out.println("workSource");
//        this. s = "constructor";
//    }
//    public String toString() {
//        return s;
//    }
//}
//
//public class SprinklerSystem {
//    private String value1,value2,value3,value4;
//    private WorkSource source = new WorkSource();
//    private int i;
//    private float f;
//
//    @Override
//    public String toString() {
//        return "SprinklerSystem{" +
//                "value1='" + value1 + '\'' +
//                ", value2='" + value2 + '\'' +
//                ", value3='" + value3 + '\'' +
//                ", value4='" + value4 + '\'' +
//                ", source=" + source +
//                ", i=" + i +
//                ", f=" + f +
//                '}';
//    }
//
//    public static void main(String[] args) {
//       SprinklerSystem sprinklerSystem = new SprinklerSystem();
//        System.out.println(sprinklerSystem);
//    }
//}
class WaterSource{
    //调用顺序是静态代码块(父类)->实例代码块(子类)->构造方法(父类子类)
     private String s;
     public WaterSource() {
         System.out.println("WaterSource的构造方法");
         s= "constructor";
     }
     public String toString() {
         return s;
     }
}

public class SprinklerSystem {
    private String value1,value2,value3;
   // private WaterSource source = new WaterSource();
    private int i;
    private float f;
    public SprinklerSystem() {
        this.value1 ="value1";
        this.value2= "value2";
        this.value3 = null;
        this.i=0;
        this.f =1.2f;
    }
    private WaterSource source = new WaterSource();
    @Override
    public String toString() {
        return "SprinklerSystem{" +
                "value1='" + value1 + '\'' +
                ", value2='" + value2 + '\'' +
                ", value3='" + value3 + '\'' +
                ", i=" + i +
                ", f=" + f +
                '}';
    }

    public static void main(String[] args) {
        SprinklerSystem sprinklerSystem = new SprinklerSystem();
        System.out.println(sprinklerSystem);
    }

}
